package com.oa.modules.approvalsec1.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.modules.approvalsec1.entity.AudioVideoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 视频教学-视频表
 *
 * @author jiangwei
 * @date 2021-03-16 09:47:45
 */
@Mapper
public interface AudioVideoDao extends BaseMapper<AudioVideoEntity> {

    /**
     * @return long
     * @Author Ark
     * @Description 查询总条数
     * @Date 15:47 2020/3/10 0010
     * @Param [page, params]
     **/
    @Select("<script>" +
            "SELECT COUNT( 1 ) FROM (" +
            "select t1.* from audio_video t1  " +
            "where 1=1 " +
            "<if test = 'params != null '> "+
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.fileTitle != null'>and t1.file_title LIKE '%${params.fileTitle}%'  </if> " +
            "<if test='params.fileType != null'>and t1.file_type = #{params.fileType} </if>" +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            ") </if> TOTAL" +
            "</script>")
    long findPage(@Param("params") Map<String, Object> params);

    /**
     * @return java.util.List
     * @Author Ark
     * @Description 查询分页数据
     * @Date 15:47 2020/3/10 0010
     * @Param [page, params]
     **/
    @Select("<script>" +
            "select t1.* from audio_video t1 " +
            "where 1=1 " +
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.fileTitle != null'>and t1.file_title LIKE '%${params.fileTitle}%'  </if> " +
            "<if test='params.fileType != null'>and t1.file_type = #{params.fileType} </if>" +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            "ORDER BY t1.CREATE_DATE desc" +
            "</script>")
    List<AudioVideoEntity> findRecords(IPage<AudioVideoEntity> page, @Param("params") Map<String, Object> params);

}
